package com.amit.jdbc.mysql;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class Lab5 {

	
	public static void main(String[] args) throws Exception {
		
		//1.load the driver class
		Class.forName("com.mysql.jdbc.Driver");
		Class.forName("oracle.jdbc.driver.OracleDriver");
		
		//2.Create the connection
		
		Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/jdbcdb","root","root");
		//Connection con1=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","amit","amit");
		
		//3.prepare the sql query
		
		String sql="select * from jlcstudents";
		
		//4.create the jdbc statement
		
		Statement st=con.createStatement();
		
		//5.submit the jdbc statement
		
		ResultSet rs=st.executeQuery(sql);
		
		//6.process the result
		
		while(rs.next())
		{
		int sid=rs.getInt(1);
		String name=rs.getString(2);
		String email=rs.getString(3);
		long phone=rs.getLong(4);
		
		System.out.println(sid+" "+name+" "+email+" "+phone);
		
		}
		
	//7.close the connection
		
		con.close();
		
		

	}

}
